<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
        }
    </style>
</head>
<body>
    <div id="app">
        <h4>v-memo性能比对指令（vue3新增）</h4>
        <p>该指令接收一个固定长度的数组作为依赖值进行记忆比对。如果数组中的每个值都和上次渲染的时候相同，则整个包裹区的更新会被跳过。</p>
        <ul>
            <li v-for=" u in users" :key="u.id" v-memo="[u.state]">
                <span :style=" getColor(u) ">
                    {{ u.name }}
                    <input type="button" value="state" @click=" u.state=!u.state ">
                </span>
            </li>
        </ul>
    </div>
    <script src="../assets/mock/mock-min.js"></script>
    <script type="module"> 
        import { createApp } from "../assets/vue3/vue.esm-browser.js";
        createApp({
            data(){
                return {
                    users:Mock.mock({
                        "list|10":[
                            {
                                id:"@id",
                                name:"@cname",
                                "state|1":[false,true]
                            }
                        ]
                    }).list
                }
            },
            methods:{
                getColor(u){
                    console.log(u.name)
                    return u.state?"color:red;":"color:green;"
                }
            }
        }).mount("#app")
    </script>
</body>
</html>